package cn.edu.jxau.test;

import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.NoSuchElementException;
import java.util.Objects;

public class Main {

	public static void main(String[] args) {

		int[] arr = new int[] { 1, 2, 3, 4, 5, 6, 7 };
		foo(arr);
		System.out.println(Arrays.toString(arr));
	}

	public static void foo(int[] arr) {

		Objects.requireNonNull(arr, "参数arr不能为null");
		if (arr.length == 1) {
			return;
		}
		int low = 0;
		int high = arr.length - 1;
		while (low < high) {
			while (low < high && (arr[low] & 1) == 1) {
				low++;
			}
			while (low < high && (arr[high] & 1) == 0) {
				high--;
			}
			if (low < high) {
				int temp = arr[low];
				arr[low] = arr[high];
				arr[high] = temp;
				low++;
				high--;
			}
		}
	}
}